package com.cwj.thread;

import org.openjdk.jol.info.ClassLayout;

/**
 * @author chenwujie
 * @date 2021-02-20 16:44
 */
public class SynchronizedTest {
    public static void main(String[] args) throws InterruptedException {
        Thread.sleep(5_000L);
        System.out.println(Integer.toBinaryString(Thread.currentThread().hashCode()));
        SynchronizedTest synchronizedTest = new SynchronizedTest();
        System.out.println(ClassLayout.parseInstance(synchronizedTest).toPrintable());
        synchronized (synchronizedTest){
            System.out.println(ClassLayout.parseInstance(synchronizedTest).toPrintable());
        }
        Thread thread = new Thread() {
            @Override
            public void run() {
                synchronized (synchronizedTest) {
                    System.out.println(ClassLayout.parseInstance(synchronizedTest).toPrintable());
                }
            }
        };
        thread.start();

    }

}
